package com.whq.thrift.api.web.admin.service.test.impl;

import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.whq.thrift.api.common.spring.datasource.DataSourceContextHolder;
import com.whq.thrift.api.web.admin.db.test.IceTest;
import com.whq.thrift.api.web.admin.db.test.IceTestMapper;
import com.whq.thrift.api.web.admin.service.test.IceTestService;

@Service
public class IceTestServiceImpl implements IceTestService{
	
	@Autowired
	private IceTestMapper iceTestMapper;

	public int addIceTest(IceTest iceTest) {
		DataSourceContextHolder.set("dataSourceAdmin");
		if (iceTest == null) {
			return 0; 
		}

		Date now = new Date();
		iceTest.setUpdateTime(now);
		iceTest.setCreateTime(now);

		return this.iceTestMapper.addIceTest(iceTest);
	}

	public List<IceTest> getIceTestByMap(Map<String, Object> whereParams, int beginIndex, int maxCount) {
		DataSourceContextHolder.set("dataSourceAdmin");
		whereParams.put("beginIndex", beginIndex);
		whereParams.put("maxCount", maxCount);
		return this.iceTestMapper.findIceTestByMap(whereParams);
	}

	public int delIceTest(int id) {
		DataSourceContextHolder.set("dataSourceAdmin");
		return this.iceTestMapper.delIceTest(id);
	}

	public IceTest getIceTestById(int id) {
		DataSourceContextHolder.set("dataSourceAdmin");
		return this.iceTestMapper.getIceTestById(id);
	}

	public int getIceTestCount(Map<String, Object> whereParams) {
		DataSourceContextHolder.set("dataSourceAdmin");
		return this.iceTestMapper.findIceTestCount(whereParams);
	}

}
